#include <iostream>
using namespace std;

class GrandFather{
    public:
        string name; // 姓名
    protected:
        int tel;    // 电话
    private:
        int passwd; // 密码
    public:
        GrandFather(){cout << "GrandFather 无参构造" << endl;}
        GrandFather(string n, int t, int p):name(n), tel(t), passwd(p){
            cout << "GrandFather 有参构造" << endl;
        }
        ~GrandFather(){cout << "GrandFather 析构函数" << endl;}
        void show(){
            cout << "GrandFather show() : " << name << " " << tel << " " << passwd << endl;
        }
};

// ----在Father类中----
// public:
//     string name;
// protected:
//     int tel;
// private:
//     string book;
// 无法直接访问:
//     int passwd;

class Father:public GrandFather{
    private:
        string book; // Father类新增的成员 书
    public:
        Father(){cout << "Father 无参构造" << endl;}
        Father(string n, int t, int p, string b):GrandFather(n, t, p), book(b){
            cout << "Father 有参构造" << endl;
        }
        ~Father(){cout << "Father 析构函数" << endl;}
        void show(){
            // 无法直接访问 父类中 private 权限的成员
            // cout << passwd << endl;
            cout << "Father show() : " << book << endl;
        }
};


// ----在Son类中----
// public:
//     string name;
// protected:
//     int tel;
// private:
//     string toy;
// 无法直接访问:
//     string book;
//     int passwd;
class Son:public Father{
    private:
        string wanju; // Son类新增的成员  玩具
    public:
        Son(){cout << "Son 无参构造" << endl;}
        Son(string n, int t, int p, string b, string w):Father(n, t, p, b), wanju(w){
            cout << "Son 有参构造" << endl;
        }
        ~Son(){cout << "Son 析构函数" << endl;}
        void show(){
            // 无法直接访问 父类中 private 权限的成员
            // cout << book << endl;
            // cout << passwd << endl;
            cout << "Son show() : " << wanju << endl;
        }
};

int main(int argc, const char *argv[]){
    Son s("小明", 7796456, 111222, "面向对象程序设计之美", "电脑");
    s.Father::GrandFather::show(); // GrandFather show
    s.Father::show(); // Father show
    s.show(); // Son show

    return 0;
}